<?php
namespace Admin\Controller;

class FieldController extends BaseController{
    public function index(){
    	$Field = D('Field');
    	$object = $Field->all($this->page($Field->total()));
    	$this->assign('All',$object);
    	$this->display();
    }
    
    public function selected(){
    	if (I('get.id')){
    		$Field = D('Field');
    		$object = $Field->one();
    		if (!$object) $this->failed('不存在此字段！');
    		if ($object['selected'] == 0){
    			if (!$Field->selected(1)) $this->failed('设置默认字段失败！');
    		}else{
    			if (!$Field->selected(0)) $this->failed('取消默认字段失败！');
    		}
    		$this->success(C('PREV_URL'));
    	}else{
    		$this->failed('非法操作！');
    	}
    }
}